package cn.hiapi.shopkeeper.entity.order;

import cn.hiapi.basic.entity.BasicEntity;
import cn.hiapi.basic.serializer.LongToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * @author AdinZ
 * @date 2022/12/30 22:15
 */
@Entity
@Table(name = "hiapi_shopkeeper_activity_group_order")
@ApiModel(description = "团购订单")
@Getter
@Setter
public class ActivityGroupOrder extends BasicEntity {
    @Id
    @GeneratedValue(generator = "snowflake")
    @GenericGenerator(name = "snowflake", strategy = "cn.hiapi.basic.id.SnowflakeId")
    @JSONField(serializeUsing = LongToStringSerializer.class)
    private Long id;

    @ApiModelProperty("店铺id")
    private long shopId;
    @ApiModelProperty("买家id")
    private long buyerId;

    @ApiModelProperty("活动id")
    private long aid;

    @ApiModelProperty("商品名称")
    private String title;

    @ApiModelProperty("商品图片")
    private String thumb;

    @ApiModelProperty("团购价格")
    @Column(columnDefinition = "decimal(10,2)")
    private BigDecimal price = BigDecimal.ZERO;

    @ApiModelProperty("原价")
    @Column(columnDefinition = "decimal(10,2)")
    private BigDecimal costPrice = BigDecimal.ZERO;


    @ApiModelProperty("成团人数")
    private int groupNum;

    @ApiModelProperty("已付人数")
    private int buyNum;
    @ApiModelProperty("团购超时时间 分钟")
    private int timeout;

    @ApiModelProperty("团购状态,0 等待团长支付,1待成团,2已成团,3成团失败,-1团购关闭")
    private int status;

    @ApiModelProperty("团购到期时间")
    private long expire;

    @ApiModelProperty("创建时间")
    private long created = System.currentTimeMillis();

    @ApiModelProperty("更新时间")
    private long updated = System.currentTimeMillis();

    @Version
    private long version;

}
